package com.itheima.refect;

import com.itheima.domain.Student;

import java.lang.reflect.Method;
import java.util.Arrays;

/*
使用反射获取类中的方法
Method
s 多个
不带s 单个
带 declared 全部
不带  只能public


 */
public class Demo04 {

    public static void main(String[] args) throws Exception {
        Class<Student> clazz = (Class<Student>) Class.forName("com.itheima.domain.Student");
        //出了能获取公有的 还能获取爹的
        Method[] methods = clazz.getMethods();
        System.out.println(Arrays.toString(methods));
        //只能获取本类的方法  可以获取私有的
        Method[] declaredMethods = clazz.getDeclaredMethods();
        System.out.println(Arrays.toString(declaredMethods));

        Method sing = clazz.getMethod("sing");
        System.out.println(sing);
        Method dance = clazz.getMethod("dance",String.class);
        System.out.println(dance);
        Method play = clazz.getMethod("playbasketball",String.class,int.class);
        System.out.println(play);

        Method study = clazz.getDeclaredMethod("sing", String.class);
        System.out.println(study);
    }

}
